package String.api;

public class StringTest05 {
    public static void main(String[] args) {
        //replace
        //返回从替换所有出现的导致一个字符串 oldChar在此字符串 newchar
        String s1 = "你好世界你好世界";
        String s2 = s1.replace("世界","中国");
        System.out.println(s2);

        String s3 ="你二大爷和他二大爷都叫二大爷";
        System.out.println(s3.replace("大爷","**"));
        //String [] split(String regex)
        //将此字符串分割为给定的regular expression的匹配
        String s4 ="你好，我好，大家好，广州好迪";
        String [] split = s4.split("，");
        System.out.println(split);//引用型类型
        //循环遍历打印内容
        for (int i =0;i<split.length;i++){
            System.out.println(split[i]);
        }
        /**
         * String substring (int beginIndex,int endIndex)
         * 返回一个字符串，该字符串是此字符串的子字符串
         * beginIndex 开始索引
         * endIndex 结束索引 包含头，不包含尾
         *
         */
        String s5 = "你好刘亦菲";
        String substring = s5.substring(2,5);
        System.out.println(substring);

        //String toUpperCase()
        //将所以在此字符 String使用默认语言环境的规则大写
        //tolowerCase小写
        String s6 = "abcABC";
        System.out.println(s6.toUpperCase());
        System.out.println(s6.toLowerCase());

        //trim 去除前后空格
        String s7 = "    adb de    ";
        System.out.println(s7);
        System.out.println(s7.trim());
    }
}
